package com.jpm.jroguefx.utilities.tools;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class MonsterListBuilder {

    public static void main(String[] args) {

        File dir = new File("C:/Users/jonboy/workspace/JRogueFX/src/com/jpm/jroguefx/graphics/monsters");
        File output = new File("C:/Users/jonboy/workspace/JRogueFX/src/com/jpm/jroguefx/resources/monsterList.xml");

        try {

            if (output.exists()) {
                output.delete();
            }
            output.createNewFile();
            PrintWriter pw = new PrintWriter(new FileWriter(output));
            pw.println("<monsters>");

            String val = "";

            for (File dir2 : dir.listFiles()) {


                for (File file : dir2.listFiles()) {

                    String name = file.getName();
                    String shortName = name.substring(0, name.lastIndexOf("."));
                    pw.println("<monster>");
                    pw.println("<id>" + shortName.toUpperCase() + "</id>");
                    pw.println("<img>" + shortName + "</img>");
                    pw.println("<name>" + shortName + "</name>");
                    pw.println("<group>" + dir2.getName() + "</group>");

                    if (!dir2.getName().equals(val)) {
                        System.out.println(dir2.getName().toUpperCase() + ",");
                        val = dir2.getName();
                    }

                    for (String tag : new String[]{"lvl", "hp", "dmg", "wis", "dex", "ac", "xp", "sumnum",}) {
                        pw.println("<" + tag + ">0</" + tag + ">");
                    }

                    pw.println("<summon></summon>");
                    pw.println("<abilities></abilities>");
                    pw.println("</monster>");
                }
            }
            pw.println("</monsters>");

            pw.close();


        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
